jQuery(function($) {
	$('table th input:checkbox').on('click' , function(){
		var that = this;
		$(this).closest('table').find('tr > td:first-child input:checkbox')
		.each(function(){
			this.checked = that.checked;
			$(this).closest('tr').toggleClass('selected');
		});
	});

	$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
	function tooltip_placement(context, source) {
		var $source = $(source);
		var $parent = $source.closest('table')
		var off1 = $parent.offset();
		var w1 = $parent.width();

		var off2 = $source.offset();
		var w2 = $source.width();

		if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
		return 'left';
	}
	
	$("#to_add_id").click(function(){
		var form = document.formName;
		form.action=$(this).attr("url");
		form.submit();
	});
	
	$("#save_id").click(function(){
		var form = document.formName;
		form.action=$(this).attr("url");
		form.submit();
	});
	
	$("#search_id").click(function(){
		var form = document.formName;
		$("#curpage_id").val(1);
		form.action=$(this).attr("url");
		form.submit();
	});
	
	$(".return_class").click(function(){
		var form = document.formName;
		form.action=$(this).attr("url");
		form.submit();
	});
	
	$("#reset_id").click(function(){
		var form = document.bankFromName;
		form.action=$(this).attr("url");
		form.submit();			
	});
})

function get(url) {
	var form = document.formName;
	form.action=url;
	form.submit();	
}

